﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using MySql.Data.MySqlClient;
using Cinemon;
using Cinemon.MySqlConnect;


public partial class _Default : BaseClass
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //tbxUsername.Focus();

    }

    protected void Login_Click(object sender, EventArgs e)
    {
        if (!string.IsNullOrEmpty(tbxUsername.Text))
        {
			DatabaseManager dbm = new DatabaseManager();
            List<MySqlParameter> sqlParams = new List<MySqlParameter>();

            sqlParams.Add(new MySqlParameter("strUsername", tbxUsername.Text));
            sqlParams.Add(new MySqlParameter("strPassword", tbxPassword.Text));
            DataTable dtUserId = dbm.ExecuteQuery("validateLogin", sqlParams);

            if (dtUserId != null && dtUserId.Rows.Count > 0)
            {
                BaseAttributes.UserID = Convert.ToInt32(dtUserId.Rows[0]["user_id"]);
                ClientScript.RegisterStartupScript(this.GetType(), "Login Success", "window.location = 'MainFrameSet.aspx';", true);
            }
            else
            {
                ClientScript.RegisterStartupScript(this.GetType(), "Login Fail", "LoginFailed();", true);
            }
        }
    }

    protected void Register_Click(object sender, EventArgs e)
    {
        ClientScript.RegisterStartupScript(this.GetType(), "Register", "window.location = 'UserRegistration.aspx';", true);
    }

    protected void btnForgotPassword_Click(object sender, EventArgs e)
    {
        ClientScript.RegisterStartupScript(this.GetType(), "Register", "window.location = 'ForgotPassword.aspx';", true);
    }
}